<template>
	<view class="ps_box">
		<u-image class="Home_position" @click="backToHome" width="120rpx" height="120rpx" :src="homeImg"></u-image>
		<u-image class="Pre_position" @click="backToPre" width="120rpx" height="120rpx" :src="backImg"></u-image>
		<!-- <u-icon class="Home_position"  name="arrow-left-double" color="#4DC0D9" size="40"></u-icon>
			<u-icon class="Pre_position"   name="home-fill" color="#4DC0D9" size="40"></u-icon> -->
		<!-- <u-icon color="#2979ff" size="28" name="hone-fill"></u-icon> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				homeImg: require('@/static/icon/return_home@2x.png'),
				backImg: require('@/static/icon/return_upper_page@2x.png'),
			}
		},
		onLoad() {

		},
		methods: {
			isTabBarPage() {
				// 检查当前页面是否是tabBar页面
				const currentPage = getCurrentPages().pop();
				const indexPages = ['pages/index/index', 'pages/index/work', 'pages/index/my']
				//console.log(currentPage.route);
				if (currentPage && currentPage.route) {
					return indexPages.includes(currentPage.route)
					//return currentPage.route.indexOf('pages/index') !== -1;
				}
				return false;
			},
			backToPre() {
				if (!this.isTabBarPage()) { //不是主页才能返回
					uni.navigateBack({
						delta: 1
					})
				}
			},
			backToHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.ps_box {
		// height: 200rpx;
		position: fixed;
		display: flex;
		flex-direction: column;
		bottom: 25vh;
		right: 0;
		z-index: 9;
		border-radius: 30rpx;
		//border: 1px solid #4DC0D9;
		padding: 5px 10px;

		.Home_position {
			padding-bottom: 10px;
			//border-bottom:1px solid #4DC0D9 ;
		}

		.Pre_position {
			padding-top: 20rpx;
		}
	}
</style>